package com.inspur.cloud.service.dataspace;

import com.inspur.cloud.dao.dataspace.HiveResourceDao;
import com.inspur.cloud.entity.dataspace.HiveResourceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class HiveResourceService {
    @Autowired
    private HiveResourceDao hiveResourceDao;
    @Transactional(transactionManager = "transactionManagerDataspace")
    public void save(HiveResourceEntity hiveResourceEntity){
        hiveResourceDao.save(hiveResourceEntity);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public void deleteById(Integer id){
        hiveResourceDao.deleteById(id);
    }
    public HiveResourceEntity findHiveResourceEntityById(Integer id){
        return hiveResourceDao.findHiveResourceEntityById(id);
    }
    public HiveResourceEntity findByDatabaseName(String databaseName){
        return hiveResourceDao.findByDatabaseName(databaseName);
    }
    public HiveResourceEntity findFirstByOwner(Integer owner){
        return hiveResourceDao.findFirstByOwner(owner);
    }
    public HiveResourceEntity findByTableNameAndParentId(String tableName, Integer parentId){
        return hiveResourceDao.findByTableNameAndParentId(tableName,parentId);
    }
    public  HiveResourceEntity findByColumnNameAndParentId(String columnName, Integer parentId){
        return hiveResourceDao.findByColumnNameAndParentId(columnName,parentId);
    }
    public List<HiveResourceEntity> findByParentId(Integer parentId){
        return hiveResourceDao.findByParentId(parentId);
    }

    public List<HiveResourceEntity> findAll() {
        return hiveResourceDao.findAll();
    }
    public List<Integer> findIdByParentId(Integer parentId){
        return  hiveResourceDao.findIdByParentId(parentId);
    }
    @Transactional
    public Integer deleteByParentId(Integer parentId){
        return hiveResourceDao.deleteByParentId(parentId);
    }
    public List<HiveResourceEntity> findByLevelAndStatus(Integer level, Integer status){
        return hiveResourceDao.findByLevelAndStatus(level,status);
    }
    public List<HiveResourceEntity> findByLevelAndStatusAndOwner(Integer level, Integer status, Integer owner){
        return hiveResourceDao.findByLevelAndStatusAndOwner(level,status,owner);
    }
    public Integer findSonNum(Integer id){
        return hiveResourceDao.findSonNum(id);
    }
    @Transactional
    public Integer hideByParentId(Integer parentId){
        return hiveResourceDao.hideByParentId(parentId);
    }
}
